Skip to content

Conversation

@danieljvickers
Copy link
Member

@danieljvickers danieljvickers commented Jul 17, 2025

User description

Description

I originally created this branch just to add a little better --help messages to the toolchain. Some of the functionality that is available was now shown in the help message. Now those should appear when requested.

This small branch also got a little sidetracked removing some of the s_prohibit_abort calls and replacing them with PROHIBIT macros. I removed all of the subroutine calls that I thought made sense, but there are still two that I think should be there because of the way that we would pass in the condition.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Scope

  • This PR comprises a set of related changes with a common goal

If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration

  • I reran the entire test suite locally after making changes
  • I checked the --help output, which looks as desired
  • I manually changed the case files to make sure that we were correctly hitting the PROHIBIT macros

Test Configuration:

  • What computers and compilers did you use to test this:

Checklist

  • I have added comments for the new code
  • I added Doxygen docstrings to the new code
  • I have made corresponding changes to the documentation (docs/)
  • I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • I have added example cases in examples/ that demonstrate my new feature performing as expected.
    They run to completion and demonstrate "interesting physics"
  • I ran ./mfc.sh format before committing my code
  • New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

If your code changes any code source files (anything in src/simulation)

To make sure the code is performing as expected on GPU devices, I have:

  • Checked that the code compiles using NVHPC compilers
  • Checked that the code compiles using CRAY compilers
  • Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
  • Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
  • Enclosed the new feature via nvtx ranges so that they can be identified in profiles
  • Ran a Nsight Systems profile using ./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR
  • Ran a Rocprof Systems profile using ./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.
  • Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature

PR Type

Enhancement, Documentation


Description

  • Add help messages to MFC toolchain commands

  • Replace s_prohibit_abort calls with PROHIBIT macros

  • Improve argument parser documentation

  • Add missing command line options to help


Diagram Walkthrough

flowchart LR
  A["Toolchain Args"] --> B["Enhanced Help Messages"]
  C["Prohibit Calls"] --> D["PROHIBIT Macros"]
  E["Bootstrap Scripts"] --> F["Help Functions"]
  B --> G["Better User Experience"]
  D --> G
  F --> G
Loading

File Walkthrough

Relevant files
Enhancement
m_check_ib_patches.fpp
Replace prohibit calls with PROHIBIT macros                           

src/pre_process/m_check_ib_patches.fpp

  • Replace s_prohibit_abort calls with @:PROHIBIT macros
  • Consolidate error checking logic for IB patches
  • Move geometry validation to top of loop
+5/-10   
m_check_patches.fpp
Refactor patch validation with PROHIBIT macros                     

src/pre_process/m_check_patches.fpp

  • Replace multiple s_prohibit_abort calls with @:PROHIBIT macros
  • Add validation for deprecated geometry numbers (6, 7, 13, 15)
  • Consolidate patch validation logic
+15/-20 
args.py
Add missing commands to argument parser                                   

toolchain/mfc/args.py

  • Add missing subparsers for load, lint, format, spelling commands
  • Improve help message formatting and descriptions
  • Add proper punctuation to help strings
+13/-9   
Documentation
format.sh
Add help functionality to format script                                   

toolchain/bootstrap/format.sh

  • Add show_help() function with usage information
  • Add -h/--help option handling
  • Document available command line options
+15/-0   
modules.sh
Add help documentation to modules script                                 

toolchain/bootstrap/modules.sh

  • Add comprehensive show_help() function
  • Document computer and mode options
  • Add -h/--help argument parsing
+19/-0   

@qodo-merge-pro
Copy link
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Typo Bug

There's a typo in the error message where 'patch_ib' is used instead of 'patch_icpp' for inactive patches, which could confuse users about which patch type is causing the error.

@:PROHIBIT(patch_icpp(i)%geometry .ne. dflt_int, "Inactive patch defined. "// &
    "patch_ib("//trim(iStr)//")%geometry not be set for inactive patches. "// &
    "Patch "//trim(iStr)//" is inactive as the number of patches is "//trim(num_patches_str))
Missing Parsers

The code adds subparsers for load, lint, format, and spelling commands but these parsers are not used anywhere in the rest of the function, potentially causing runtime errors when these commands are invoked.

load       = parsers.add_parser(name="load",       help="Loads the MFC environment with source.", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
lint       = parsers.add_parser(name="lint",       help="Lints all code after editing.",          formatter_class=argparse.ArgumentDefaultsHelpFormatter)
formatting = parsers.add_parser(name="format",     help="Formats all code after editing.",        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
spelling   = parsers.add_parser(name="spelling",   help="Runs the spell checker after editing.",  formatter_class=argparse.ArgumentDefaultsHelpFormatter)

@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Jul 17, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix incorrect variable reference in error message
Suggestion Impact:The suggestion was implemented - the error message was corrected to reference patch_icpp instead of patch_ib, making it consistent with the variable being checked

code diff:

-                    "patch_ib("//trim(iStr)//")%geometry not be set for inactive patches. "// &
+                @:PROHIBIT(patch_icpp(i)%geometry /= dflt_int, "Inactive patch defined. "// &
+                    "patch_icpp("//trim(iStr)//")%geometry not be set for inactive patches. "// &

The error message references patch_ib instead of patch_icpp, which is
inconsistent with the variable being checked. This will confuse users about
which patch type is causing the error.

src/pre_process/m_check_patches.fpp [92-94]

 @:PROHIBIT(patch_icpp(i)%geometry .ne. dflt_int, "Inactive patch defined. "// &
-    "patch_ib("//trim(iStr)//")%geometry not be set for inactive patches. "// &
+    "patch_icpp("//trim(iStr)//")%geometry not be set for inactive patches. "// &
     "Patch "//trim(iStr)//" is inactive as the number of patches is "//trim(num_patches_str))
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a copy-paste error in an error message where patch_ib is used instead of patch_icpp, which would be confusing for the user.

Medium
General
Fix grammatical error in error message
Suggestion Impact:The suggestion was implemented - the grammatical error in the error message was fixed by changing "not be set" to "must not be set"

code diff:

+                @:PROHIBIT(patch_ib(i)%geometry /= dflt_int, "Inactive IB patch defined. "// &
+                    "patch_ib("//trim(iStr)//")%geometry must not be set for inactive patches.")

The error message contains a grammatical error with "not be set" which should be
"must not be set" for proper English grammar and consistency with similar error
messages.

src/pre_process/m_check_ib_patches.fpp [71-72]

 @:PROHIBIT(patch_ib(i)%geometry .ne. dflt_int, "Inactive IB patch defined. "// &
-    "patch_ib("//trim(iStr)//")%geometry not be set for inactive patches.")
+    "patch_ib("//trim(iStr)//")%geometry must not be set for inactive patches.")
Suggestion importance[1-10]: 3

__

Why: The suggestion correctly identifies and fixes a grammatical error in an error message, improving its clarity and professionalism.

Low
  • Update

@sbryngelson sbryngelson merged commit 565178a into MFlowCode:master Jul 18, 2025
31 checks passed
@danieljvickers danieljvickers deleted the Add-mfc-commands-to-argparser branch September 12, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants